package com.gxa.web_admin.controller.zy;


import com.gxa.common.base.RespResult;
import com.gxa.modules.dto.OrderInsertDTO;
import com.gxa.modules.dto.OrderPageDTO;
import com.gxa.modules.entity.CrmOrder;
import com.gxa.modules.entity.CrmOrderGoods;
import com.gxa.modules.entity.CrmOrderState;
import com.gxa.modules.mapper.OrderMapper;
import com.gxa.modules.service.OrderService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.naming.spi.ResolveResult;
import java.math.BigDecimal;

/**
 * Create with IntelliJ IDEA.
 * Description:
 * User: ZY
 * Date: 2023-03-10
 * Time: 18:35
 */
@RestController
@RequestMapping("/order")
@Api(tags = "订单管理",value = "订单管理")
public class OrderController {
    @Autowired
    OrderService orderService;



    @RequestMapping(value ="/findOrderList",method = RequestMethod.GET)
    public RespResult findOrderList(Integer currentPagecurrentPage, Integer pageSize, String timeSlot){
        System.out.println("findOrderList");

        return orderService.findOrderList(currentPagecurrentPage,pageSize,timeSlot);
    }





    @RequestMapping(value ="/findOrderListByCondition",method = RequestMethod.GET)
    public RespResult findOrderListByCondition(Integer currentPagecurrentPage,Integer pageSize,String timeSlot,String condition){
        return orderService.findOrderListByCondition(currentPagecurrentPage,pageSize,timeSlot,condition);
    }





    @RequestMapping(value ="/findOrderListByOrderConditions",method = RequestMethod.POST)
    public RespResult findOrderListByOrderConditions(@RequestBody OrderPageDTO orderPageDTO){
        return orderService.findOrderListByOrderConditions(orderPageDTO);
    }




    @RequestMapping(value ="/findOrderListByCustomer",method = RequestMethod.GET)
    public RespResult findOrderListByCustomer(Integer customerId){
        return orderService.findOrderListByCustomer(customerId);
    }




    @RequestMapping(value ="/findOrderListById",method = RequestMethod.GET)
    public RespResult findOrderListById(Integer orderId){
        return orderService.findOrderListById(orderId);
    }





    @RequestMapping(value ="/updateOrderStateById",method = RequestMethod.POST)
    public RespResult updateOrderStateById(@RequestBody CrmOrderState crmOrderState){

        System.out.println("updateOrderStateById");

        return orderService.updateOrderStateById(crmOrderState);
    }



    @RequestMapping(value ="/addOrderGoodsById",method = RequestMethod.POST)
    public RespResult addOrderGoodsById(@RequestBody CrmOrderGoods crmOrderGoods){
        return orderService.addOrderGoodsById(crmOrderGoods);
    }





    @RequestMapping(value ="/updateOrderGoodsById",method = RequestMethod.POST)
    public RespResult updateOrderGoodsById(@RequestBody CrmOrderGoods crmOrderGoods){
        return orderService.updateOrderGoodsById(crmOrderGoods);
    }




    @RequestMapping(value ="/updatedReceiverById",method = RequestMethod.POST)
    public RespResult updatedReceiverById(Integer orderId,BigDecimal received){
        return orderService.updatedReceiverById(orderId,received);
    }





    @RequestMapping(value ="/addOrder",method = RequestMethod.POST)
    public RespResult addOrder(@RequestBody OrderInsertDTO orderInsertDTO){
        return orderService.addOrder(orderInsertDTO);
    }



    @RequestMapping(value ="/updateOrderById",method = RequestMethod.POST)
    public RespResult updateOrderById(@RequestBody OrderInsertDTO orderInsertDTO){
        return orderService.updateOrderById(orderInsertDTO);
    }
}
